﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using System.Workflow.Activities;

using HT.Model;
using HT.Business;


namespace HT.Workflow
{
    class ProgramTesting
    {
        public static void Main(string[] args)
        {
            AutoResetEvent waitHandle = new AutoResetEvent(false);

            //全部通过的测试
            //StartupWorkflowTesting();
            //RMApproveTesting();
            //ACApproveTesting();
            //VPApproveTesting();
            //PRApproveTesting();

            
            //RM拒绝的测试
            //StartupWorkflowTesting();
            //RMRejectTesting();
           
            //没有RM的测试
            //StartupWorkflowTesting();
            //ACApproveTesting();
           
            waitHandle.WaitOne();
        }

        private static void StartupWorkflowTesting()
        {
            ReimbursementHandler reimbursementHandler = new ReimbursementHandler();
            //reimbursementHandler.CreateReimbursementWorkflow("test1", 100, "dinner");
            reimbursementHandler.CreateReimbursementWorkflow("test2", 100, "dinner"); //no report manager                                  
        }

        private static void RMApproveTesting()
        {
            ReimbursementHandler reimbursementHandler = new ReimbursementHandler();
            List<ReimbursementInfo> reimbursementInfoList = reimbursementHandler.SearchWaitingReimbursementInfo("test7");           
           
            for (int i = 0; i < reimbursementInfoList.Count; i++)
            {
                ReimbursementInfo reimbursementInfo = reimbursementInfoList[i];
                reimbursementHandler.RaiseReimbursementEvent(reimbursementInfo.InstanceID, ReimbursementEvent.RMApproveEvent, "可以");
            }                                  
        }

        private static void ACApproveTesting()
        {
            ReimbursementHandler reimbursementHandler = new ReimbursementHandler();
            List<ReimbursementInfo> reimbursementInfoList = reimbursementHandler.SearchWaitingReimbursementInfo("test2");

            for (int i = 0; i < reimbursementInfoList.Count; i++)
            {                
                ReimbursementInfo reimbursementInfo = reimbursementInfoList[i];
                reimbursementHandler.RaiseReimbursementEvent(reimbursementInfo.InstanceID, ReimbursementEvent.ACApproveEvent, "行");              
            }

        }

        private static void VPApproveTesting()
        {
            ReimbursementHandler reimbursementHandler = new ReimbursementHandler();
            List<ReimbursementInfo> reimbursementInfoList = reimbursementHandler.SearchWaitingReimbursementInfo("test3");

            for (int i = 0; i < reimbursementInfoList.Count; i++)
            {
                ReimbursementInfo reimbursementInfo = reimbursementInfoList[i];
                reimbursementHandler.RaiseReimbursementEvent(reimbursementInfo.InstanceID, ReimbursementEvent.VPApproveEvent, "没问题");  
            }

        }

        private static void PRApproveTesting()
        {
            ReimbursementHandler reimbursementHandler = new ReimbursementHandler();            
            List<ReimbursementInfo> reimbursementInfoList = reimbursementHandler.SearchWaitingReimbursementInfo("test4");

            for (int i = 0; i < reimbursementInfoList.Count; i++)
            {
                ReimbursementInfo reimbursementInfo = reimbursementInfoList[i];
                reimbursementHandler.RaiseReimbursementEvent(reimbursementInfo.InstanceID, ReimbursementEvent.PRApproveEvent, "要得");  
            }

        }

        private static void RMRejectTesting()
        {
            ReimbursementHandler reimbursementHandler = new ReimbursementHandler();
            List<ReimbursementInfo> reimbursementInfoList = reimbursementHandler.SearchWaitingReimbursementInfo("test7");

            for (int i = 0; i < reimbursementInfoList.Count; i++)
            {
                ReimbursementInfo reimbursementInfo = reimbursementInfoList[i];
                reimbursementHandler.RaiseReimbursementEvent(reimbursementInfo.InstanceID, ReimbursementEvent.RMRejectEvent, "你太过分了啥");
            }     

        }
    }
}
